import 'package:bottom_picker/bottom_picker.dart';
import 'package:flutter/material.dart';

///关键字搜索弹窗
class SearchSelectDialog extends StatelessWidget {
  TextEditingController controller = TextEditingController();

  dynamic Function(dynamic) callback;

  SearchSelectDialog({super.key, required this.callback});

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      backgroundColor: Colors.white,
      title: const Text("提示"),
      content: SizedBox(
        width: 480,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            TextField(
              decoration: const InputDecoration(hintText: '请输入关键字'),
              controller: controller,
            )
          ],
        ),
      ),
      actions: [
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          child: const Text("取消"),
        ),
        TextButton(
            onPressed: () {
              Navigator.of(context).pop();
              debugPrint(controller.text);
              //todo 查询数据

              //显示picker
              BottomPicker(
                items: [
                  Center(
                    child: Text('Leonardo DiCaprio'),
                  ),
                  Center(
                    child: Text('Johnny Depp'),
                  ),
                  Center(
                    child: Text('Robert De Niro'),
                  ),
                  Center(
                    child: Text('Tom Hardy'),
                  ),
                  Center(
                    child: Text('Ben Affleck'),
                  ),
                ],
                pickerTitle: const Text("请选择", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15)),
                buttonContent: const Center(
                  child: Text(
                    '确定',
                    style: TextStyle(color: Colors.white),
                  ),
                ),
                onSubmit: callback,
              ).show(context);
            },
            child: const Text("确定")),
      ],
    );
  }
}
